/*
* @Author: Srain
* @Date:   2018-07-25 16:00:14
* @Last Modified by:   Srain 
* @Last Modified time: 2018-10-06 10:05:19
*/


require('./index.css');
require('page/common/nav/index.js');

var _mm             = require('util/mm.js');
var _project        = require('service/project-service.js');
var templateIndex   = require('./index.string');


//page 逻辑部分
var page = {
	data : {
        id : _mm.getUrlParam('id') || '', 
    },
    init: function(){
        this.onLoad();
        this.bindEvent();
    },
    onLoad : function(){
        // 加载活动信息
        this.loadDetail();
    },
    // 加载活动信息
    loadDetail : function(){
        var projectHtml = '';
        _project.getProjectDetail(this.data.id,function(res){
            projectHtml = _mm.renderHtml(templateIndex, res);
            $('.panel').html(projectHtml);
        }, function(errMsg){
            _mm.errorTips(errMsg);
        });
    },
    bindEvent : function(){
        var _this = this;
        // 点击提交按钮后的动作
        $(document).on('click', '.btn-success', function(){    
                _project.JoinPractice({
                activityId   : _this.data.id,
                }, function(res){
                   // _mm.successTips(msg);
                 window.location.href = './user-project.html';
                }, function(errMsg){
                    _mm.errorTips(errMsg);
                });
        });   
    }
};

$(function(){
    page.init();
});